﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Entities.MetaDataSchema
{
    public class RelationShip : Entities.Entity
    {

        
        private Table _masterTable;
        public Table MasterTable
        {
            set { _masterTable = value; }
            get { return _masterTable; }
        }

        private Table _childTable;
        public Table ChildTable
        {
            set { _childTable = value; }
            get { return _childTable; }
        }

        private List<Column> _masterColumns;
        public List<Column> MasterColumns
        {
            set { _masterColumns = value; }
            get { return _masterColumns; }
        }
        public Database ParentDatabase
        {
            set { _Parent = value; }
            get { return _Parent as Database; }
        }
        private List<Column> _childColumns;
        public List<Column> ChildColumns
        {
            set { _childColumns = value; }
            get { return _childColumns; }
        }

        public static RelationShip GetByName(List<RelationShip> relationShips, string searchName)
        {
            foreach (RelationShip row in relationShips)
            {
                if (row.Name == searchName)
                    return row;
            }
            return null;
        }

        public override void UnSelect()
        {
            
            foreach (Column cols in ChildColumns)
            {
                cols.UnSelect();
            }
            foreach (Column cols in MasterColumns)
            {
                cols.UnSelect();
            }

        }
        


    }
}
